﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ExcelMapper.Utils
{
    public class Validation
    {
        public bool ValidateDocument(List<ExcelDocument> excelDocumentList, string documentName, string columnName, string primaryKeyValue)
        {
           
            if(string.IsNullOrEmpty(documentName) || string.IsNullOrWhiteSpace(documentName))
            {
                throw new Exception("documentName parameter is null or empty");
            }
            if (string.IsNullOrEmpty(columnName) || string.IsNullOrWhiteSpace(columnName))
            {
                throw new Exception("columnName parameter is null or empty");
            }
            if (string.IsNullOrEmpty(primaryKeyValue) || string.IsNullOrWhiteSpace(primaryKeyValue))
            {
                throw new Exception("primaryKeyValue parameter is null or empty");
            }

            var document = excelDocumentList.Where(x => x.Name.ToLower() == documentName.ToLower()).FirstOrDefault();

            if(document == null)
            {
                return false;
            }
            else
            {
                return true;
            }


        }
    }
}
